home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.std.c
- Subject: Re: sizeof(char) ~= sizeof(float)
- Date: Sun, 17 Mar 96 00:59:21 GMT
- Organization: none
- Message-ID: <827024361snz@genesis.demon.co.uk>
- References: <WALD.96Feb24131532@woodpecker.lcs.mit.edu> <4gr3d1$dca@usenet.pa.dec.com> <TANMOY.96Feb27114201@qcd.lanl.gov>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <TANMOY.96Feb27114201@qcd.lanl.gov>
- tanmoy@qcd.lanl.gov "Tanmoy Bhattacharya" writes:
-
- >In article <DnFr78.1wo@ukpsshp1.serigate.philips.nl>
- >baynes@ukpsshp1.serigate.philips.nl (Stephen Baynes) writes:
- >
- >SB: Tanmoy Bhattacharya (tanmoy@qcd.lanl.gov) wrote:
- >SB: : In article <4gr3d1$dca@usenet.pa.dec.com>
- >SB: : diamond@tbj.dec.com (Norman Diamond) writes:
- >SB: <snip - copying data by using chars of different sorts vs memcpy >
- >SB: : This was a free-standing implementation, and memcpy may be absent. (In
- >SB: : a hosted implementation, as all read/write is done as if through
- >SB: : getc/putc which handles unsigned char values, and binary files written
- >SB: : out must be read back unchanged, the situation is impossible).
- >SB:
- >SB: That read/write is done by getc/putc does not imply very much about copying
- >SB: chars. I don't see any requirement that fwrite/fread use one putc/getc per
- >SB: byte(ie char) of memory. Fwrite could use one per bit writing the
- >values 'Y' or
- >SB: 'N' if it wanted so long as fread will read it back again. My
- >understanding
- >SB: is that the use of getc/putc means you can write a file with
- >fwrite, copy it
- >SB: with getc/putc and read the copy with fread to get what you started with.
- >
- >I understood it to mean that I could take the same (void*) pointer to
- >the data, and call putc repeatedly on the successive bytes of the
- >data, and the resulting file is identical to doing an fwrite. I think
- >the standard should clarify its meaning.
-
- OK, I'm a little late in getting round to this! :-)
-
- This is a property that fread/fwrite really must have if they are to be
- of much use. Without it you can't use them for random access reading/writing
- of record because you don't know how large those records are going to
- end up being in the file, even using a binary stream.
-
- This would also bring into question whether:
-
- fwrite(str, 1, strlen(str), fp)
-
- has the same effect (ignoring the return values) as:
-
- fputs(str, fp)
-
- for valid arguments.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-